home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8567 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Tradition or what?
  5. Date: 4 Mar 96 17:51:12 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.825961872@rscernix>
  8. References: <4g0elg$mdr@redstone.interpath.net> <4h0bbo$c0q@fohnix.metronet.com> <4h7ce0$ojd@news.interpath.net> <4h85sm$lm0@texas.nwlink.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4h85sm$lm0@texas.nwlink.com> Teresa Reiko <tjr19@mail.nwlink.com> writes:
  13.  
  14. >In this book and others, notably 'Code Complete', these programming
  15. >guides published by Microsoft Press, it is evident why Microsoft put
  16. >so many bugs in Windows 95.  Here are the three worst Microsoft
  17. >coding rules, in my opinion at least:
  18. >
  19. >Every line of code must contain a comment.
  20. >Any number greater than 2 must be a named constant.
  21. >No procedure may be longer than 25 lines.
  22. >
  23. >If you follow these rules, you can be sure to write buggy, inefficient
  24. >code that is difficult to revise and will generally look 'dirty'.
  25. >Of course, if this is your intent, that's OK, but...
  26.  
  27. Actually, the second rule is quite good (except that '2' should be replaced
  28. by '1' :-)  Magic constants embedded in the code are a huge nuisance
  29. for maintenability.  If you have to change an explicit (aka magic) constant
  30. in a piece of code, how can you be sure that you aren't going to break
  31. anything?  By changing a macro definition, you _know_ that you won't
  32. break anything, because all the dependencies of that macro will be
  33. automatically taken care of by the compiler (and your "make" utility).
  34.  
  35. In a previous life, my boss was also doing Fortran programming.  All his
  36. array dimensions were funny looking numbers (e.g. instead of the popular
  37. ARRAY(100,100) he would use ARRAY(99,101)), so that he could use his
  38. text editor to find all the places which needed to be changed when one
  39. of the arrays had to be redimensioned.
  40.  
  41. Dan
  42. --
  43. Dan Pop
  44. CERN, CN Division
  45. Email: danpop@mail.cern.ch 
  46. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  47.